package com.study.dao.impl;

import com.study.bean.vo.BuildingCount;
import com.study.dao.EchatsDao;
import com.study.util.JDBCUtils;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;

import java.util.List;

public class EchatsDaoImpl implements EchatsDao {
    private JdbcTemplate template = new JdbcTemplate(JDBCUtils.getDataSource());

    @Override
    public List selectAll() {
        String sql = "SELECT  building_id,COUNT(*) amount\n" +
                "FROM  students\n" +
                "GROUP BY building_id";
        List<BuildingCount> query = template.query(sql, new BeanPropertyRowMapper<>(BuildingCount.class));
        return query;
    }

    @Override
    public List selectAll2() {
        return null;
    }


}
